var vm_jieyujingfeiguanli = new Vue({
    el: "#jieyujingfeiguanli",
    data: {
        deptid: $("#deptid").val(),		// 单位ID
        jigoujibie: $("#jigoujibie").val(),
        parentid : $("#parentid").val(),

        yuelist: [],// 退款list

        messagecontent : '',
        fuzerenshoujihaoma : '',

        yue: {
            yue:0,
            daifa:0,
            jieyu:0,
        }, //余额
    },
    created: function () {
        var _this = this;

        if (_this.deptid=='000'){
            $("#tuihuitab").hide();
        }

        _this.bindYue();
        _this.bindYueList();
    },
    watch: {
    },
    methods: {

        bindYue: function () {
            var _this = this;
            $.post('/system/danweijingfei/findone', {
                deptid: _this.deptid,
            }, function (ppData) {
                if (ppData != null) {
                    if (ppData.result == 1) {
                        if(ppData.resultContent!=null)
                            _this.yue = ppData.resultContent;
                    } else {
                        layer.alert(ppData.message)
                    }
                }
            }, "json");
        },

        // 根据单位ID查询专家变动申请信息
        bindYueList: function () {
            var _this = this;

            var parentid = "";

            if(_this.parentid!=""){
                parentid = _this.parentid;
            }else{
                parentid = _this.deptid;
            }

            $.post('/system/danweijingfei/findbyparentid', {
                parentid: parentid,
            }, function (ppData) {
                if (ppData != null) {
                    if (ppData.result == "1") {
                        var data = ppData.resultContent;
                        _this.yuelist = data;
                    } else {
                        layer.alert(ppData.message)
                    }
                }
            }, "json");
        },

        //
        toCustomYueList : function(yueitem){
            $.modal.openTab("单位余额详情",'system/jintieguanli/jieyujingfeiguanli?parentid='+yueitem.deptid,false);
        },

        toSendMessage:function(yueitem){
            var _this = this;

            _this.fuzerenshoujihaoma = yueitem.fuzerenshouji;
            var str = "您有：" + (yueitem.jieyujingfei == null?"0" : yueitem.jieyujingfei)+"元滞留经费，请及时退回。"
            _this.messagecontent = str;
            $("#messageModalLabel").html("发送短信");
            $("#messageModal").modal()
        },

        sendmessage:function(){
            var _this = this;

            var jingfeipici_layer = layer.open({type:3});
            $.post('/system/messagecenter/send_piliang', {
                messagecontent : _this.messagecontent,
                phones : _this.fuzerenshoujihaoma,
                rdm : Math.random()
            },function(ppData) {
                layer.close(jingfeipici_layer);

                if (ppData != null) {
                    if (ppData.result==1){
                        layer.open({
                            time: 1000,
                            btn: [],
                            content: "发送成功!",
                        });
                        $("#messageModal").modal('hide');
                    }else{
                        layer.alert(ppData.message);
                    }
                }
            },"json");
        },
    },
})